home *** CD-ROM | disk | FTP | other *** search
/ The Programmer Disk / The Programmer Disk (Microforum).iso / xpro / c / pro22 / cbgetr.c < prev    next >
Encoding:
C/C++ Source or Header  |  1990-06-20  |  1.8 KB  |  85 lines

  1. /*    Copyright (c) 1989 Citadel    */
  2. /*       All Rights Reserved        */
  3.  
  4. /* #ident    "@(#)cbgetr.c    1.4 - 90/06/20" */
  5.  
  6. /* ansi headers */
  7. #include <errno.h>
  8.  
  9. /* library headers */
  10. #include <blkio.h>
  11. #include <lseq.h>
  12.  
  13. /* local headers */
  14. #include "cbase_.h"
  15.  
  16. /*man---------------------------------------------------------------------------
  17. NAME
  18.      cbgetr - get cbase record
  19.  
  20. SYNOPSIS
  21.      #include <cbase.h>
  22.  
  23.      int cbgetr(cbp, buf)
  24.      cbase_t *cbp;
  25.      void *buf;
  26.  
  27. DESCRIPTION
  28.      The cbgetr function reads the current record of cbase cbp into
  29.      buf.  buf must point to a storage area at least as large as the
  30.      record size for cbp.
  31.  
  32.      cbgetr will fail if one or more of the following is true:
  33.  
  34.      [EINVAL]       cbp is not a valid cbase pointer.
  35.      [EINVAL]       buf is the NULL pointer.
  36.      [CBELOCK]      cbp is not read locked.
  37.      [CBENOPEN]     cbp is not open.
  38.      [CBENREC]      The record cursor for cbp is null.
  39.  
  40. SEE ALSO
  41.      cbrcursor, cbrecsize, cbgetrf, cbputr.
  42.  
  43. DIAGNOSTICS
  44.      Upon successful completion, a value of 0 is returned.  Otherwise,
  45.      a value of -1 is returned, and errno set to indicate the error.
  46.  
  47. ------------------------------------------------------------------------------*/
  48. int cbgetr(cbp, buf)
  49. cbase_t *cbp;
  50. void *buf;
  51. {
  52.     /* validate arguments */
  53.     if (!cb_valid(cbp) || buf == NULL) {
  54.         errno = EINVAL;
  55.         return -1;
  56.     }
  57.  
  58.     /* check if not open */
  59.     if (!(cbp->flags & CBOPEN)) {
  60.         errno = CBENOPEN;
  61.         return -1;
  62.     }
  63.  
  64.     /* check if not read locked */
  65.     if (!(cbp->flags & CBRDLCK)) {
  66.         errno = CBELOCK;
  67.         return -1;
  68.     }
  69.  
  70.     /* check if cursor is null */
  71.     if (lscursor(cbp->lsp) == NULL) {
  72.         errno = CBENREC;
  73.         return -1;
  74.     }
  75.  
  76.     /* read field */
  77.     if (lsgetr(cbp->lsp, buf) == -1) {
  78.         CBEPRINT;
  79.         return -1;
  80.     }
  81.  
  82.     errno = 0;
  83.     return 0;
  84. }
  85.